package com.flink.scala

import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment, createTypeInformation}

object wordcount {
  def main(args: Array[String]): Unit = {
    //创建编程入口环境
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
    //获取一个stream
    val source: DataStream[String] = env.socketTextStream("linux01", 9999)
    //逻辑处理
    val value: DataStream[(String, Int)] = source.flatMap(f => f.split("\\s=")).map(s => (s, 1)).keyBy(_._1).sum(1 )
    //输出
    value.print()
    //提交
    env.execute()
  }

}
